<template>
  <div class="body">
    <!-- <el-button @click="$router.go(0)" type="info" icon="el-icon-refresh-right"></el-button> -->
    <!-- <el-button type="success" icon="el-icon-plus" @click="handleAdd">添加</el-button>
    <el-button type="primary" icon="el-icon-edit" @click="handleUpdate">编辑</el-button> -->
    <!-- <el-button type="danger" @click="del()" icon="el-icon-delete">删除</el-button> -->
    <!-- <el-button type="primary" icon="el-icon-upload2">导出</el-button> -->
    <el-row class="mb8">
      <el-col :span="19">
        <el-button
          type="info"
          @click="shuaxin"
          icon="el-icon-refresh-right"
        ></el-button>
        <!-- <el-button type="success" @click="handleAdd" icon="el-icon-plus">上传</el-button> -->
      </el-col>
      <el-col :span="5" class="seach">
        <el-input v-model="params.keywords" placeholder="请输入"></el-input>
        <el-button
          type="primary"
          icon="el-icon-search"
          @click="shuaxin"
        ></el-button>
      </el-col>
    </el-row>
    <el-table
      ref="multipleTable"
      :data="guaranteelist"
      tooltip-effect="dark"
      class="table xinde"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55"></el-table-column>
      <!-- <el-table-column prop="id" label="序号" width="120"></el-table-column> -->
      <el-table-column
        prop="applyNumber"
        label="保函编号"
        :show-overflow-tooltip="true"
        width="280"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="handlerName"
        :show-overflow-tooltip="true"
        width="120"
        label="经办人"
      ></el-table-column>
      <el-table-column
        prop="username"
        :show-overflow-tooltip="true"
        width="120"
        label="反担保人"
      ></el-table-column>
      <el-table-column
        prop="mobile"
        :show-overflow-tooltip="true"
        width="160"
        label="反担保人手机号"
        align="center"
      ></el-table-column>
      <!-- <el-table-column prop="cardcode" :show-overflow-tooltip="true" 
               width="220" label="身份证号码" align="center"></el-table-column> -->
      <el-table-column
        prop="statusTxt"
        :show-overflow-tooltip="true"
        width="120"
        label="认证状态"
      ></el-table-column>
      <el-table-column
        prop="signtime"
        :show-overflow-tooltip="true"
        width="220"
        label="认证时间"
      ></el-table-column>
      <el-table-column
        prop="applyName"
        :show-overflow-tooltip="true"
        width="260"
        label="保函名称"
        align="center"
      ></el-table-column>
      <!-- <el-table-column prop="fdb_filepath" :show-overflow-tooltip="true" 
               width="220" label="反担保协议"  align="center">
                 <template slot-scope="scope">
         <a :href="scope.row.fdb_filepath" target="_blank" rel="noopener noreferrer">查看</a>
            </template>
               </el-table-column> -->
      <el-table-column
        prop="gtype"
        align="gtype"
        :show-overflow-tooltip="true"
        width="120"
        label="保函类型"
      ></el-table-column>
      <el-table-column
        prop="biddingNumber"
        :show-overflow-tooltip="true"
        width="220"
        align="center"
        label="标段编号"
      ></el-table-column>
      <el-table-column width="220" label="操作" align="center">
        <template slot-scope="scope">
          <el-button size="mini" @click="fanbianji(scope.row)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 新增或修改 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="序号">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="项目编号">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="项目名称">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="担保机构名称">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">确定</el-button>
          <el-button @click="cancel">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <div class="block">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-sizes="[10, 20, 30]"
        :page-size="params.pageSize"
        :current-page.sync="params.pageNum"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import { guarantee } from "@/api/guarantee";
export default {
  data() {
    return {
      params: {
        pageSize: 10,
        pageNum: 0,
        keywords: "",
      },
      guaranteelist: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {
        name: "",
      },
      // 表单校验
      rules: {},
      total: null,
      tableData: [],
      multipleSelection: [],
    };
  },

  created() {
    this.guarantees();
  },
  methods: {
    shuaxin() {
      this.guarantees();
    },
    //页面
    guarantees() {
      // this.params.user_id = sessionStorage.getItem("user_id");
      guarantee(this.params).then((response) => {
        console.log(response);
        this.guaranteelist = response.data.rows;
        this.total = response.data.total;
      });
    },
    // 删除

    handleSizeChange(val) {
      this.params.pageSize = val;
      this.guarantees();
    },
    handleCurrentChange(val) {
      this.params.pageNum = val
      this.guarantees();
    },
    // 表单重置
    reset() {
      this.form = {
        name: "",
      };
    },
    fanbianji(e) {
      console.log("yulan", e);
      this.$router.push({
        name: "fdbxq",
        query: { company_id: e.applyNumber },
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    //新增按钮操作
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加档案架";
    },
    //修改
    handleUpdate() {
      this.reset();
      this.open = true;
      this.title = "修改档案架";
    },
    //提交按钮
    onSubmit() {
      alert("submit!");
      this.open = false;
    },
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
  },
};
</script>

<style scoped>
.body {
  /* width: 86vw;
  height: 91vh; */
}

.table {
  width: 100%;
  margin-top: 2vh;
}

.block {
  position: fixed;
  bottom: 20px;
  right: 20px;
}
</style>
